package com.hefei.hight.reflection;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

/**
 * @author caizhengjun
 * @date 2020/9/5 11:48 上午
 */
public class Test06 {
    public static void main(String[] args) throws Exception {

        Class<?> clazz = Class.forName("com.hefei.hight.reflection.Person");
        Object o = clazz.newInstance();
        Field name = clazz.getDeclaredField("name");
        name.setAccessible(true);
        name.set(o, "蔡正峻");
        Method method = clazz.getDeclaredMethod("sayHello");

        method.invoke(o);
    }
}
